<? include "server_config.php" ?>
<result>
<?
$user_idx = $_SESSION['user_idx'];
$sql = "
	SELECT COUNT(*) FROM ndd_comment_recommend WHERE comment_idx=$comment_idx AND user_idx=$user_idx;
";
$result = mysql_query($sql,$connect);
$row = mysql_fetch_row($result);
if ($row[0] >= 1)
{
	$sql="
		DELETE FROM ndd_comment_recommend WHERE comment_idx=$comment_idx AND user_idx=$user_idx;
	";
	mysql_query($sql,$connect);
	$sql="
		UPDATE ndd_comment SET recommend_count=recommend_count-1 WHERE comment_idx=$comment_idx;
	";
	mysql_query($sql,$connect);
	echo '<process>cancel</process>';
} else {
	$sql="
		INSERT INTO ndd_comment_recommend VALUES ($comment_idx, $user_idx);
	";
	mysql_query($sql,$connect);
	$sql="
		UPDATE ndd_comment SET recommend_count=recommend_count+1 WHERE comment_idx=$comment_idx;
	";
	mysql_query($sql,$connect);
	echo '<process>recommend</process>';
}
$sql="
	SELECT recommend_count FROM ndd_comment WHERE comment_idx=$comment_idx;
";
$result = mysql_query($sql,$connect);
$row = mysql_fetch_row($result);
$count = $row[0];
?>
	<count><? echo $count; ?></count>
</result>
